<?php
namespace modules\post\action\show\modules;

use library\PageAction;
use idea\ap\Ap;
use idea\mvc\Mvc;
use helper\ErrorNo;
use helper\Util;

/**
 * AddAction class file
 * 添加文档类别模型表单展示
 * @author 宋欢 <iphper@yeah.net>
 * @version $Id: AddAction.php 1 2013-02-08 00:48:06Z huan.song $
 * @package modules.post.action.show.modules
 * @since 1.0
 */
class AddAction extends PageAction
{
	/**
	 * (non-PHPdoc)
	 * @see idea\mvc\interfaces.Action::run()
	 */
	public function run()
	{
		$request = Ap::getRequest();
		$ret = array();
		
		$do = $request->getParam('do', '');
		if ($do === 'post') {
			$ret = Util::getService('Modules', 'post')->add($request->getPost());
			if ($ret['err_no'] === ErrorNo::SUCCESS_NUM) {
				Util::forward('edit', Mvc::$controller, Mvc::$module, $ret);
			}
		}
		
		$this->render($ret);
	}
}
